package com.newsmanagement.dao;

import com.newsmanagement.entity.NewsContentEntity;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

/**
 * @author xbr
 * 2017/12/5
 * 社会动态操作
 */
@Mapper
public interface ISocialDevelopmentServiceDao {

    /**
     * 社会动态列表数量
     * @return 总数量
     */
    @Select("SELECT COUNT(*) FROM social_development_t WHERE DELETE_FLAG = 1")
    int getDevelopmentListCount();

    /**
     * 社会动态列表
     * @return 总数量
     */
    @Select("SELECT * FROM social_development_t WHERE DELETE_FLAG = 1 ORDER BY ORDER_NUMBER DESC")
    List<Map<String ,Object>> getDevelopmentList();

    /**
     * 添加动态信息
     * @param createUser 创建人id
     * @param developmentTitle 动态标题
     * @param developmentTxt 分类内容
     * @param releaseDevelopment 是否发布动态:1,发布；0，不发布；默认为1
     * @return 添加的数据条数
     */
    @Insert("INSERT INTO social_development_t(" +
            "DEVELOPMENT_TITLE ,DEVELOPMENT_TXT ,CREATE_USER ,CREATE_DATE ,RELEASE_DEVELOPMENT" +
            ") " +
            "VALUES (" +
            "#{arg1} ,#{arg2}, #{arg0}, NOW(), #{arg3}" +
            ")")
    int releaseDevelopment(Integer createUser ,String developmentTitle,String developmentTxt ,Integer releaseDevelopment);

    /**
     * 查询动态信息
     * @param createUser 创建人id
     * @param developmentId 动态id
     * @return List<Map<String ,Object>>
     */
    @Select("SELECT * FROM SOCIAL_DEVELOPMENT_LIKE_T WHERE DEVELOPMENT_ID = #{arg1} AND CREATE_USER = #{arg0}")
    List<Map<String ,Object>> queryDevelopmentByUserIdDevelopmentId(Integer createUser ,Integer developmentId);


    /**
     * 添加动态信息
     * @param createUser 创建人id
     * @param developmentId 动态id
     * @return 添加的数据条数
     */
    @Insert("INSERT INTO SOCIAL_DEVELOPMENT_LIKE_T (DEVELOPMENT_ID ,CREATE_USER ,CREATE_DATE ) VALUES (#{arg1} ,#{arg0} ,NOW())")
    int likeDevelopment(Integer createUser ,Integer developmentId);

}
